package cn.schoolwow.quickflow.service.executor.putInstanceData;

import cn.schoolwow.quickflow.QuickFlowExecutor;
import cn.schoolwow.quickflow.domain.FlowDataFeature;
import cn.schoolwow.quickflow.domain.FlowExecutorConfig;
import cn.schoolwow.quickflow.dto.FlowContextDataRange;

public class QuickFlowExecutorPutInstanceDataOperationImpl implements QuickFlowExecutorPutInstanceDataOperation {
    private FlowExecutorConfig flowExecutorConfig;

    public QuickFlowExecutorPutInstanceDataOperationImpl(FlowExecutorConfig flowExecutorConfig) {
        this.flowExecutorConfig = flowExecutorConfig;
    }

    @Override
    public QuickFlowExecutor putThreadLocalInstanceData(Object instance) {
        flowExecutorConfig.flowContext.putThreadLocalInstanceData(instance);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putThreadLocalInstanceData(Object instance, Class classType) {
        flowExecutorConfig.flowContext.putThreadLocalInstanceData(instance, classType);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putCurrentFlowInstanceData(Object instance) {
        flowExecutorConfig.flowContext.putCurrentFlowInstanceData(instance);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putCurrentFlowInstanceData(Object instance, Class classType) {
        flowExecutorConfig.flowContext.putCurrentFlowInstanceData(instance, classType);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putCurrentCompositeFlowInstanceData(Object instance) {
        flowExecutorConfig.flowContext.putCurrentCompositeFlowInstanceData(instance);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putCurrentCompositeFlowInstanceData(Object instance, Class classType) {
        flowExecutorConfig.flowContext.putCurrentCompositeFlowInstanceData(instance, classType);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putTemporaryInstanceData(Object instance) {
        flowExecutorConfig.flowContext.putTemporaryInstanceData(instance);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putTemporaryInstanceData(Object instance, Class classType) {
        flowExecutorConfig.flowContext.putTemporaryInstanceData(instance, classType);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putInstanceData(Object instance) {
        if(null==flowExecutorConfig.parentFlowExecutorConfig){
            flowExecutorConfig.flowContext.putInstanceData(instance, FlowDataFeature.RequestData);
        }else{
            flowExecutorConfig.flowContext.putInstanceData(instance);
        }
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putInstanceData(Object instance, Class classType) {
        if(null==flowExecutorConfig.parentFlowExecutorConfig){
            flowExecutorConfig.flowContext.putInstanceData(instance, classType, FlowDataFeature.RequestData);
        }else{
            flowExecutorConfig.flowContext.putInstanceData(instance, classType);
        }
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putContextInstanceData(Object instance) {
        flowExecutorConfig.flowContext.putContextInstanceData(instance);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putContextInstanceData(Object instance, Class classType) {
        flowExecutorConfig.flowContext.putContextInstanceData(instance, classType);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putContextTemporaryInstanceData(Object instance) {
        flowExecutorConfig.flowContext.putContextTemporaryInstanceData(instance);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putContextTemporaryInstanceData(Object instance, Class classType) {
        flowExecutorConfig.flowContext.putContextTemporaryInstanceData(instance, classType);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putInstanceData(Object instance, FlowContextDataRange flowContextDataRange, FlowDataFeature... flowDataFeatures) {
        flowExecutorConfig.flowContext.putInstanceData(instance, flowContextDataRange, flowDataFeatures);
        return flowExecutorConfig.quickFlowExecutor;
    }

    @Override
    public QuickFlowExecutor putInstanceData(Object instance, Class classType, FlowContextDataRange flowContextDataRange, FlowDataFeature... flowDataFeatures) {
        flowExecutorConfig.flowContext.putInstanceData(instance, classType, flowContextDataRange, flowDataFeatures);
        return flowExecutorConfig.quickFlowExecutor;
    }

}
